<!-- 添加监管员/组 -->
<template>
  <el-dialog title="添加监管员/组" :visible.sync="dialogVisible" width="45%">
    <el-descriptions :column="2" border>
      <el-descriptions-item>
        <template slot="label">监管团队名称</template>
        <el-input v-model="jgtdxx.tdmc" />
      </el-descriptions-item>
      <!-- <el-descriptions-item>
        <template slot="label">负责人</template>
        {{ jgtdxx.tdfzrmc }}
      </el-descriptions-item> -->
      <el-descriptions-item>
        <template slot="label">参与轮案</template>
        <el-radio-group v-model="jgtdxx.sfcyla">
          <el-radio label="Y">是</el-radio>
          <el-radio label="N">否</el-radio>
        </el-radio-group>
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">参与自动轮案</template>
        <el-radio-group v-model="jgtdxx.sfzdcyla">
          <el-radio label="Y">是</el-radio>
          <el-radio label="N">否</el-radio>
        </el-radio-group>
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">互斥规则</template>
        <el-radio-group v-model="jgtdxx.sfhc">
          <el-radio label="Y">是</el-radio>
          <el-radio label="N">否</el-radio>
        </el-radio-group>
      </el-descriptions-item>
    </el-descriptions>
    <span slot="footer">
      <el-button type="primary" :loading="loading" @click="saveData"
        >保存</el-button
      >
      <el-button @click="closeDialog">关闭</el-button>
    </span>
  </el-dialog>
</template>
<script>
import tdxxService from '@/api/tdxx.js'
export default {
  data () {
    return {
      loading: false,
      dialogVisible: false,
      // 监管团队信息
      jgtdxx: {}
    }
  },
  methods: {
    /** 打开弹窗 */
    openDialog () {
      this.dialogVisible = true
    },
    /** 保存 */
    saveData () {
      const { dwbm, dwmc } = this.$store.state.personInfo
      const params = {
        ...this.jgtdxx,
        dwbm,
        dwmc
      }
      this.loading = true
      tdxxService
        .saveTdxx(params)
        .then(res => {
          this.closeDialog()
          this.$emit('refresh')
          this.$message({ type: 'success', message: '保存成功' })
        })
        .catch(err => {
          !err.isError &&
            this.$message({ type: 'warning', message: err.message })
        })
        .finally(() => {
          this.loading = false
        })
    },
    closeDialog () {
      this.dialogVisible = false
      this.jgtdxx = {}
    }
  }
}
</script>
